package com.example.testactivity0323;

import android.content.res.Configuration;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

public class ConfigActivity extends AppCompatActivity {
    TextView ori,navigation,touch,mnc;

    TextView tvShowOri,tvShowNav,tvShowMnc,tvShowTouch;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_config);

        //  Configuration cfg=getResources().getConfiguration();
        ori=findViewById(R.id.ori);
        navigation=findViewById(R.id.navigation);
        touch=findViewById(R.id.touch);
        mnc=findViewById(R.id.mnc);
        Button button7=findViewById(R.id.button);
        button7.setOnClickListener(view->{
                    Configuration cfg =getResources().getConfiguration();


                    tvShowOri=findViewById(R.id.ori);
                    tvShowNav=findViewById(R.id.navigation);
                    tvShowTouch=findViewById(R.id.touch);
                    tvShowMnc=findViewById(R.id.mnc);

                    String screen = cfg.orientation == Configuration.ORIENTATION_LANDSCAPE ? "横向屏幕": "竖向屏幕";
                    String mncCode = cfg.mnc + "";
                    String naviName = cfg.orientation == Configuration.NAVIGATION_NONAV ? "没有方向控制":
                            cfg.orientation == Configuration.NAVIGATION_WHEEL ? "滚轮控制方向":
                                    cfg.orientation == Configuration.NAVIGATION_DPAD ? "方向键控制方向 ": "轨迹球控制方向";
                    tvShowNav.setText(naviName);
                    String touchName = cfg.touchscreen ==
                            Configuration.TOUCHSCREEN_NOTOUCH ? "无触摸屏": cfg.touchscreen == Configuration.TOUCHSCREEN_STYLUS ? "触摸笔式触摸屏": "接受手指的触摸屏";
                    tvShowOri.setText(screen);
                    tvShowMnc.setText(mncCode);
                    tvShowTouch.setText(touchName);
                }
        );



    }
}